package com.shrct.businessprocess.product.impl;

import com.shrct.businessprocess.product.RCIdentifiableNormalProductEntry;
import com.shrct.businessprocess.product.RCIdentifiableNormalProductPurchaseInfo;
import com.shrct.businessprocess.product.impl.RCIdentifiableNormalProductEntryImpl;
import com.shrct.businessprocess.product.impl.RCProductPurchaseInfoImpl;
import com.shrct.businessprocess.product.proxy.RCIdentifiableNormalProductPurchaseInfoProxy;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCIDENTIFIABLENORMALPRODUCTPURCHASEINFO_TYPE")
public class RCIdentifiableNormalProductPurchaseInfoImpl extends RCProductPurchaseInfoImpl implements RCIdentifiableNormalProductPurchaseInfo {
  public RCIdentifiableNormalProductPurchaseInfoImpl() {
    super();
  }
  
  public RCIdentifiableNormalProductPurchaseInfoImpl(final RCIdentifiableNormalProductEntry product) {
    super();
    this.product = product;
  }
  
  @JoinColumn(name = "product_id")
  @ManyToOne(targetEntity = RCIdentifiableNormalProductEntryImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCIdentifiableNormalProductEntry product;
  
  public RCIdentifiableNormalProductEntry getProduct() {
    return this.product;
  }
  
  public RCIdentifiableNormalProductPurchaseInfo setProduct(final RCIdentifiableNormalProductEntry product) {
    this.product = product;
    return this;			
    
  }
  
  public String getProductDesc() {
    String _entityName = this.product.getEntityName();
    return _entityName;
  }
  
  public static RCIdentifiableNormalProductPurchaseInfo create(final RCIdentifiableNormalProductEntry product, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.product.RCIdentifiableNormalProductPurchaseInfo rCIdentifiableNormalProductPurchaseInfo = new com.shrct.businessprocess.product.impl.RCIdentifiableNormalProductPurchaseInfoImpl(
    	product
    );
    objectFactory.create(rCIdentifiableNormalProductPurchaseInfo);
    return rCIdentifiableNormalProductPurchaseInfo;			
    
  }
  
  public static RCIdentifiableNormalProductPurchaseInfo createRCIdentifiableNormalProductPurchaseInfoImpl(final RCIdentifiableNormalProductEntry product, final IObjectFactory objectFactory, final Procedure1<RCIdentifiableNormalProductPurchaseInfo> init) {
    com.shrct.businessprocess.product.RCIdentifiableNormalProductPurchaseInfo rCIdentifiableNormalProductPurchaseInfo = new com.shrct.businessprocess.product.impl.RCIdentifiableNormalProductPurchaseInfoImpl(
    	product
    );
    objectFactory.create(rCIdentifiableNormalProductPurchaseInfo);
    init.apply(rCIdentifiableNormalProductPurchaseInfo);
    
    return rCIdentifiableNormalProductPurchaseInfo;			
    
  }
  
  public RCIdentifiableNormalProductPurchaseInfoProxy toProxy() {
    com.shrct.businessprocess.product.proxy.RCIdentifiableNormalProductPurchaseInfoProxy proxy = new com.shrct.businessprocess.product.proxy.RCIdentifiableNormalProductPurchaseInfoProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
